import dotenv from "dotenv";
import express from "express";
import cors from "cors";
import morgan from "morgan";
import userRouter from "./routes/user.route";
import roleRouter from "./routes/role.route";
import departmentRouter from "./routes/department.route";
import permissionRouter from "./routes/permission.route";
dotenv.config();
const app = express();
app.use(cors());
app.use(express.json());
app.use(morgan("dev"));

const apiRouter = express.Router();
apiRouter.use("/user", userRouter); // 用户
apiRouter.use("/role", roleRouter); // 角色
apiRouter.use("/department", departmentRouter); // 角色
apiRouter.use("/permission", permissionRouter);
app.use("/", apiRouter);

const PORT = process.env.PORT || 3000;
app.listen(PORT, () =>
  console.log(`Server running on http://localhost:${PORT}`)
);
